Skip to content

test(query-devtools/contexts/ThemeContext): split 'ThemeContext' tests into a unit test file mirroring the 'src/contexts' structure#10787

Merged
sukvvon merged 1 commit into
mainfrom
test/query-devtools-themecontext-unit-tests
May 25, 2026
Merged

test(query-devtools/contexts/ThemeContext): split 'ThemeContext' tests into a unit test file mirroring the 'src/contexts' structure#10787
sukvvon merged 1 commit into
mainfrom
test/query-devtools-themecontext-unit-tests

Conversation

@sukvvon
Copy link
Copy Markdown
Collaborator

@sukvvon sukvvon commented May 25, 2026

🎯 Changes

Move the ThemeContext module-level case added in #10786 out of Devtools.test.tsx into a dedicated src/__tests__/contexts/ThemeContext.test.tsx, mirroring the src/contexts directory layout. The settings-menu Theme UI cases stay in Devtools.test.tsx because they exercise the Devtools dropdown menu and localStorage persistence, not the ThemeContext module itself.

Drop the QueryDevtoolsContext + PiPProvider + Devtools mount boilerplate and replace it with a small renderThemeProbe helper that mounts only a ThemeProbe consumer.

The new file covers the three behaviors that make up the ThemeContext module's contract:

  • default value: resolves to 'dark' when no ThemeContext.Provider wraps the consumer.
  • with a "ThemeContext.Provider" → value resolution: resolves to the value provided by the Provider ('light' / 'dark').
  • with a "ThemeContext.Provider" → reactive Accessor: reflects updates when the Provider value is a reactive Accessor, which is the production pattern that motivates createContext<Accessor<…>>.

A local type Theme = ReturnType<ReturnType<typeof useTheme>> keeps every 'light' | 'dark' literal in sync with the ThemeContext definition.

Coverage:

  • src/contexts/ThemeContext.ts: 100% (Stmts / Branch / Funcs / Lines) from this file alone.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm run test:pr.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • Tests
    • Enhanced theme context test coverage with additional scenarios for reactive updates and provider configuration.

Review Change Stack

…s into a unit test file mirroring the 'src/contexts' structure
@sukvvon sukvvon self-assigned this May 25, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 25, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f995e250-9753-4e9a-8af3-93fec432a654

📥 Commits

Reviewing files that changed from the base of the PR and between 0cfde2a and fa3f9ab.

📒 Files selected for processing (2)
  • packages/query-devtools/src/__tests__/Devtools.test.tsx
  • packages/query-devtools/src/__tests__/contexts/ThemeContext.test.tsx

📝 Walkthrough

Walkthrough

Theme context tests previously embedded in Devtools.test.tsx are extracted into a dedicated ThemeContext.test.tsx test suite. The new suite comprehensively validates default theme fallback, provider-supplied values, and reactive signal updates. The original test block and related import are removed from Devtools.test.tsx.

Changes

Theme Context Test Organization

Layer / File(s) Summary
ThemeContext test suite
packages/query-devtools/src/__tests__/contexts/ThemeContext.test.tsx
New dedicated test suite validates default theme resolution to "dark", theme resolution from provider values ("light" and "dark"), and reactive updates via SolidJS signals.
Devtools test cleanup
packages/query-devtools/src/__tests__/Devtools.test.tsx
Removed the duplicate describe('default theme') test block that validated theme fallback behavior, and removed the unused useTheme import.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • TanStack/query#10768: Extends theme behavior test coverage for ThemeContext/useTheme in Explorer tests rendering under the "light" theme.
  • TanStack/query#10786: Adds theme assertions via ThemeProbe that directly relate to the "default theme" behavior removed from Devtools.test.tsx.
  • TanStack/query#10785: Adds Devtools test assertions for the same "no provider" default-theme behavior that is being deleted in this PR.

Suggested labels

package: query-devtools

Poem

🐰 Theme tests hopped to their own cozy warren,
No more scattered among the devtools barren,
Dark defaults and light signals now shine so clear,
A test file of focus—hooray, we cheer! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: moving ThemeContext tests from Devtools.test.tsx into a dedicated unit test file that mirrors the src/contexts directory structure.
Description check ✅ Passed The PR description follows the required template with complete 'Changes' section, fully checked 'Checklist', and 'Release Impact' with appropriate selections. All sections are well-filled with specific implementation details.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/query-devtools-themecontext-unit-tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented May 25, 2026

View your CI Pipeline Execution ↗ for commit fa3f9ab

Command Status Duration Result
nx affected --targets=test:sherif,test:knip,tes... ✅ Succeeded 3m 30s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 29s View ↗

☁️ Nx Cloud last updated this comment at 2026-05-25 06:12:51 UTC

@github-actions
Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

1 package(s) bumped directly, 24 bumped as dependents.

🟩 Patch bumps

Package Version Reason
@tanstack/query-devtools 5.100.14 → 5.100.15 Changeset
@tanstack/angular-query-experimental 5.100.14 → 5.100.15 Dependent
@tanstack/angular-query-persist-client 5.100.14 → 5.100.15 Dependent
@tanstack/eslint-plugin-query 5.100.14 → 5.100.15 Dependent
@tanstack/lit-query 0.2.6 → 0.2.7 Dependent
@tanstack/preact-query 5.100.14 → 5.100.15 Dependent
@tanstack/preact-query-devtools 5.100.14 → 5.100.15 Dependent
@tanstack/preact-query-persist-client 5.100.14 → 5.100.15 Dependent
@tanstack/query-async-storage-persister 5.100.14 → 5.100.15 Dependent
@tanstack/query-broadcast-client-experimental 5.100.14 → 5.100.15 Dependent
@tanstack/query-core 5.100.14 → 5.100.15 Dependent
@tanstack/query-persist-client-core 5.100.14 → 5.100.15 Dependent
@tanstack/query-sync-storage-persister 5.100.14 → 5.100.15 Dependent
@tanstack/react-query 5.100.14 → 5.100.15 Dependent
@tanstack/react-query-devtools 5.100.14 → 5.100.15 Dependent
@tanstack/react-query-next-experimental 5.100.14 → 5.100.15 Dependent
@tanstack/react-query-persist-client 5.100.14 → 5.100.15 Dependent
@tanstack/solid-query 5.100.14 → 5.100.15 Dependent
@tanstack/solid-query-devtools 5.100.14 → 5.100.15 Dependent
@tanstack/solid-query-persist-client 5.100.14 → 5.100.15 Dependent
@tanstack/svelte-query 6.1.33 → 6.1.34 Dependent
@tanstack/svelte-query-devtools 6.1.33 → 6.1.34 Dependent
@tanstack/svelte-query-persist-client 6.1.33 → 6.1.34 Dependent
@tanstack/vue-query 5.100.14 → 5.100.15 Dependent
@tanstack/vue-query-devtools 6.1.33 → 6.1.34 Dependent

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 25, 2026

More templates

@tanstack/angular-query-experimental

npm i https://pkg.pr.new/@tanstack/angular-query-experimental@10787

@tanstack/eslint-plugin-query

npm i https://pkg.pr.new/@tanstack/eslint-plugin-query@10787

@tanstack/lit-query

npm i https://pkg.pr.new/@tanstack/lit-query@10787

@tanstack/preact-query

npm i https://pkg.pr.new/@tanstack/preact-query@10787

@tanstack/preact-query-devtools

npm i https://pkg.pr.new/@tanstack/preact-query-devtools@10787

@tanstack/preact-query-persist-client

npm i https://pkg.pr.new/@tanstack/preact-query-persist-client@10787

@tanstack/query-async-storage-persister

npm i https://pkg.pr.new/@tanstack/query-async-storage-persister@10787

@tanstack/query-broadcast-client-experimental

npm i https://pkg.pr.new/@tanstack/query-broadcast-client-experimental@10787

@tanstack/query-core

npm i https://pkg.pr.new/@tanstack/query-core@10787

@tanstack/query-devtools

npm i https://pkg.pr.new/@tanstack/query-devtools@10787

@tanstack/query-persist-client-core

npm i https://pkg.pr.new/@tanstack/query-persist-client-core@10787

@tanstack/query-sync-storage-persister

npm i https://pkg.pr.new/@tanstack/query-sync-storage-persister@10787

@tanstack/react-query

npm i https://pkg.pr.new/@tanstack/react-query@10787

@tanstack/react-query-devtools

npm i https://pkg.pr.new/@tanstack/react-query-devtools@10787

@tanstack/react-query-next-experimental

npm i https://pkg.pr.new/@tanstack/react-query-next-experimental@10787

@tanstack/react-query-persist-client

npm i https://pkg.pr.new/@tanstack/react-query-persist-client@10787

@tanstack/solid-query

npm i https://pkg.pr.new/@tanstack/solid-query@10787

@tanstack/solid-query-devtools

npm i https://pkg.pr.new/@tanstack/solid-query-devtools@10787

@tanstack/solid-query-persist-client

npm i https://pkg.pr.new/@tanstack/solid-query-persist-client@10787

@tanstack/svelte-query

npm i https://pkg.pr.new/@tanstack/svelte-query@10787

@tanstack/svelte-query-devtools

npm i https://pkg.pr.new/@tanstack/svelte-query-devtools@10787

@tanstack/svelte-query-persist-client

npm i https://pkg.pr.new/@tanstack/svelte-query-persist-client@10787

@tanstack/vue-query

npm i https://pkg.pr.new/@tanstack/vue-query@10787

@tanstack/vue-query-devtools

npm i https://pkg.pr.new/@tanstack/vue-query-devtools@10787

commit: fa3f9ab

@github-actions
Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
react full 12.11 KB (0%)
react minimal 9.08 KB (0%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant